//
//  NSURL+EasyExtend.m
//  leway
//
//  Created by 朱潮 on 14-6-5.
//  Copyright (c) 2014年 zhuchao. All rights reserved.
//

#import "NSURL+XY.h"

@implementation NSURL (XY)

- (NSDictionary *)params {
    NSMutableDictionary * mDictionary = [NSMutableDictionary dictionary];
    NSArray<NSString *>* array = [self.query componentsSeparatedByString:@"&"];
    [array enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        NSArray<NSString *>* array = [obj componentsSeparatedByString:@"="];
        NSString * key = nil;
        NSString * value = nil;
        if (array.count >= 1) {
            key = array[0];
        }
        if (array.count >= 2) {
            value = array[1];
        }
        if (key && value) {
            [mDictionary setObject:value forKey:key];
        }
    }];
    return [mDictionary copy];
}

@end
